package com.web.dao;

import com.web.entity.UserJob;
import org.apache.ibatis.annotations.*;

public interface UserJobMapper {
    @Delete({
        "delete from APP_USER_JOB",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_JOB (user_id, sex, ",
        "mobile, email, work_year, ",
        "position, tech, ",
        "is_incumbent, expertise, ",
        "create_time, modify_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{sex,jdbcType=INTEGER}, ",
        "#{mobile,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{workYear,jdbcType=VARCHAR}, ",
        "#{position,jdbcType=VARCHAR}, #{tech,jdbcType=VARCHAR}, ",
        "#{isIncumbent,jdbcType=INTEGER}, #{expertise,jdbcType=VARCHAR}, ",
        "#{createTime,jdbcType=TIMESTAMP}, #{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(UserJob record);

    int insertSelective(UserJob record);

    @Select({
        "select",
        "id, user_id, sex, mobile, email, work_year, position, tech, is_incumbent, expertise, ",
        "create_time, modify_time",
        "from APP_USER_JOB",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserJob selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserJob record);

    @Update({
        "update APP_USER_JOB",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=INTEGER},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "work_year = #{workYear,jdbcType=VARCHAR},",
          "position = #{position,jdbcType=VARCHAR},",
          "tech = #{tech,jdbcType=VARCHAR},",
          "is_incumbent = #{isIncumbent,jdbcType=INTEGER},",
          "expertise = #{expertise,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserJob record);

    UserJob findUserJob(@Param("key") String key, @Param("value") String value);

}